package com.zmn.plat.admin.controller.msg;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.zmn.plat.model.entity.inner.InnerQuery;

/**
 * 消息列表
 *
 * @author linfeng
 *
 * @since 2020-05-18 14:50:14
 */
@Controller
@RequestMapping("/msg/")
public class MsgListController extends MsgBaseController {

    /**
     * 列表
     * 
     * @author linfeng
     * @param query
     * @since 2020-05-18 14:50:14
     */
    @RequestMapping("list")
    public ModelAndView list(@ModelAttribute InnerQuery query) {
        Integer staffId = getMcStaff().getStaffId();
        query.setStaffId(staffId);
        query.setUnReadFlag(query.getUnReadFlag());
        ModelAndView modelAndView = new ModelAndView("msg/list");
        modelAndView.addObject("staffId", staffId);
        modelAndView.addObject("items", pushInfoService.listPageByQuery(query));
        modelAndView.addObject("vo", query);
        if (query.getUnReadFlag() == null || (!query.getUnReadFlag())) {
            modelAndView.addObject("flag", 1);
        } else {
            modelAndView.addObject("flag", 2);
        }
        return modelAndView;
    }
}
